package data;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Created by skywingking
 * on 2020/9/28
 */
public class Node {
    public int val;
    public Node left;
    public Node right;
    public Node next;
    public double maxVal, minVal;
    public String minStr, maxStr;
    public List<Node> children;
    public Node prev;
    public Set<String> keys;
    public int count;

    public Node() {
        this("", 0);
    }
    public Node(String key, int count) {
        this.count = count;
        keys = new HashSet<String>();
        keys.add(key);
    }

    public Node(int _val) {
        val = _val;
    }

    public Node(int _val, Node _left, Node _right, Node _next) {
        val = _val;
        left = _left;
        right = _right;
        next = _next;
    }


    public Node insert(Node node) {  // 在 this 后插入 node
        node.prev = this;
        node.next = this.next;
        node.prev.next = node;
        node.next.prev = node;
        return node;
    }

    public void remove() {
        this.prev.next = this.next;
        this.next.prev = this.prev;
    }
}
